#========================================================================
#
# FoFi library Makefile
#
# Copyright 2003 Glyph & Cog, LLC
#
#========================================================================

# includes basic building rules
# REL_ADDR has to be defined, because Makefile.rules refers 
# to the Makefile.flags
REL_ADDR = ../../../
include $(REL_ADDR)/Makefile.rules

CFLAGS   += $(EXTRA_XPDF_CFLAGS)
CXXFLAGS += $(EXTRA_XPDF_CXXFLAGS)

CXX_SRC = \
	FoFiBase.cc \
	FoFiEncodings.cc \
	FoFiTrueType.cc \
	FoFiType1.cc \
	FoFiType1C.cc

HEADERS = \
	FoFiBase.h \
	FoFiEncodings.h \
	FoFiTrueType.h \
	FoFiType1.h \
	FoFiType1C.h \
#------------------------------------------------------------------------

TARGET = $(LIBPREFIX)fofi.a
all: $(TARGET)

staticlib: $(TARGET)

#------------------------------------------------------------------------

FOFI_OBJS = \
	FoFiBase.o \
	FoFiEncodings.o \
	FoFiTrueType.o \
	FoFiType1.o \
	FoFiType1C.o

$(TARGET): deps $(FOFI_OBJS)
	$(DEL_FILE) $(TARGET)
	$(AR) $(TARGET) $(FOFI_OBJS)
	$(RANLIB) $(TARGET)

.PHONY: install-dev uninstall-dev
install-dev: staticlib $(DEV_CONFIG)
	$(MKDIR) $(INSTALL_ROOT)$(INCLUDE_PATH)/fofi
	$(COPY_FILE) $(HEADERS) $(INSTALL_ROOT)$(INCLUDE_PATH)/fofi
	$(MKDIR) $(INSTALL_ROOT)$(LIB_PATH)/fofi
	$(COPY_FILE) $(TARGET) $(INSTALL_ROOT)$(LIB_PATH)/fofi

uninstall-dev:
	cd $(INSTALL_ROOT)$(INCLUDE_PATH)/fofi && $(DEL_FILE) $(HEADERS)
	$(DEL_DIR)  $(INSTALL_ROOT)$(INCLUDE_PATH)/fofi/
	cd $(INSTALL_ROOT)$(LIB_PATH)/fofi && $(DEL_FILE) $(TARGET)
	$(DEL_DIR)  $(INSTALL_ROOT)$(LIB_PATH)/fofi/

#------------------------------------------------------------------------

clean:
	$(DEL_FILE) $(FOFI_OBJS) $(TARGET) deps

#------------------------------------------------------------------------

deps: $(HEADERS)
	$(CXX) $(MANDATORY_INCPATH) -M -MF deps $(CXX_SRC)

# This requires GNU make (or compatible) because deps file doesn't
# exist in time when invoked for the first time and thus has to
# be generated
include deps
